package com.bysj.yqsht.web.controller;

import com.bysj.yqsht.bean.CheckTeacher;
import com.bysj.yqsht.bean.CheckallTeacher;
import com.bysj.yqsht.bean.extend.CheckTeacherExtend;
import com.bysj.yqsht.bean.extend.CheckallteacherExtend;
import com.bysj.yqsht.service.ICheckallTeacherService;
import com.bysj.yqsht.utils.Message;
import com.bysj.yqsht.utils.MessageUtil;
import io.swagger.annotations.Api;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.*;

import java.util.List;

@RestController
@RequestMapping("checkallTeacher")
@Api(description = "教师考勤总记录")
public class CheckallTeacherController {
    @Autowired
    private ICheckallTeacherService checkallTeacherService;

    @GetMapping("findAll")
    public Message findAll(){
        List<CheckallTeacher> list = checkallTeacherService.findAll();
        return MessageUtil.success(list);
    }
    @GetMapping("findWithAll")
    public Message findWithAll(@RequestParam(defaultValue = "1") int pageNum, @RequestParam(defaultValue = "10") int limit){
        List<CheckallteacherExtend> list = checkallTeacherService.findWithAll(pageNum, limit);
        return MessageUtil.success(list);
    }
    @GetMapping("findWithAllBy")
    public Message findWithAll(Long teacherId,@RequestParam("classesId") Long classId){
        List<CheckallteacherExtend> list = checkallTeacherService.findWithAllBy(teacherId, classId);
        return MessageUtil.success(list);
    }
    @GetMapping("saveOrUpdate")
    public Message saveOrUpdate(CheckallTeacher checkallTeacher){
        checkallTeacherService.saveOrUpdate(checkallTeacher);
        return MessageUtil.success("新增成功");
    }
    @PostMapping("deleteById")
    public Message deleteById(Long id){
        checkallTeacherService.deleteById(id);
        return MessageUtil.success("删除成功");
    }
}
